<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增发芽率')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-ncSeedRate-add">
			<!--作物品种ID-->
			<input id="treeId" name="cropVarieties" type="hidden" value="100"/>

			<div class="form-group">
				<label class="col-sm-3 control-label">蔬菜批次：</label>
				<div class="col-sm-8">
					<input id="caiCode" name="caiCode" class="form-control" type="text">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">作物品种：</label>
				<div class="col-sm-8">
					<div class="input-group">
						<input class="form-control" name="cropVarietiesCn" type="text" required onclick="selectCaiTree()"
							   id="treeName" readonly="true">
						<span class="input-group-addon"><i class="fa fa-search"></i></span>
					</div>
				</div>

			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">育苗盘编号：</label>
				<div class="col-sm-8">
					<input id="seedCode" name="seedCode" required class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">育苗盘规格：</label>
				<div class="col-sm-8">
					<input id="seedUnit" name="seedUnit" required class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">育苗数量(株)：</label>
				<div class="col-sm-8">
					<input id="amount" name="amount" required class="form-control"  type="number" min="1" onkeyup=" value=value.replace(/^(0+)|[^\d]+/g,'')">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">播种种子数：</label>
				<div class="col-sm-8">
					<input id="seedCount" name="seedCount" class="form-control" type="number" min="1" onkeyup=" value=value.replace(/^(0+)|[^\d]+/g,'')">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">发芽/出苗数：</label>
				<div class="col-sm-8">
					<input id="seedOut" name="seedOut" required class="form-control" type="number" min="1" onkeyup=" value=value.replace(/^(0+)|[^\d]+/g,'')">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">发芽率/出苗数：</label>
				<div class="col-sm-8">
					<input id="seedRate" name="seedRate" required class="form-control" type="number" step="0.01" min="1">
				</div>
			</div>

			<div class="form-group">	
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<textarea id="remark" rows="3" name="remark" class="form-control" type="text"></textarea>
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
        var cai_prefix = ctx + "system/cai";
		var prefix = ctx + "system/ncSeedRate"
		$("#form-ncSeedRate-add").validate({
			rules:{
				xxxx:{
					required:true,
				},
			},
			focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/add", $('#form-ncSeedRate-add').serialize());
	        }
	    }

        /*蔬菜管理-新增-选择父蔬菜树*/
        function selectCaiTree() {
            var options = {
                title: '蔬菜选择',
                width: "380",
                url: cai_prefix + "/selectCaiTree/" + $("#treeId").val()+'?parentIds=210,',
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero) {
            var tree = layero.find("iframe")[0].contentWindow.$._tree;
            if ($.tree.notAllowParents(tree)) {
                var body = layer.getChildFrame('body', index);
                $("#treeId").val(body.find('#treeId').val());
                $("#treeName").val(body.find('#treeName').val());
                layer.close(index);
            }
        }

	</script>
</body>
</html>
